//
//  WaitView.m
//  BosidengIphone
//
//  Created by  on 12-2-6.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import "WaitView.h"

@implementation WaitView


- (void)initSubViews {
    isStart = NO;
    self.backgroundColor = [UIColor clearColor];
    image = [UIImage imageNamed:@"loaddingBg.png"];
    imageView = [[UIImageView alloc] initWithImage:image];
    [self addSubview:imageView];
    [imageView release];
    
    waitView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
    waitView.hidesWhenStopped = YES;
    [self addSubview:waitView];
    self.hidden = YES;
}

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self initSubViews];
    }
    return self;
}

- (id)initWithCoder:(NSCoder *)aDecoder {
    self = [super initWithCoder:aDecoder];
    if (self) {
        [self initSubViews];
    }
    return self;
}

- (void)layoutSubviews {
    [super layoutSubviews];
    imageView.frame = CGRectMake(0, 0, 80, 80);
    
    waitView.frame = CGRectMake(21, 21, 37, 37);
    /*
    if (isStart) {
        self.hidden = NO;
        [waitView startAnimating];
    } else {
        self.hidden = YES;
        [waitView stopAnimating];
    }
     */
}

- (void)dealloc {
    [super dealloc];
}

- (void)startAnimating {
    isStart = YES;
    [waitView startAnimating];
    self.hidden = NO;
}

- (void)stopAnimating {
    isStart = NO;
    [waitView stopAnimating];
    self.hidden = YES;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    // Drawing code
}
*/

@end
